package chapter04

/**
 * 九九乘法表
 */
object Test03_Practice_MulTable {
  def main(args: Array[String]): Unit = {

    for (i <- 1 to 9) {
      for (j <- 1 to i) {
        print(j + "*" + i + "=" + (i * j) + "\t")
      }
      println()
    }

    println("####################")

    for (i <- 1 to 9) {
      for (j <- 1 to i) {
        print(s"$j * $i = ${i * j} \t")
      }
      println()
    }

    println("####################")

    for (i <- 1 to 9; j <- 1 to i) {
      print(s"$j * $i = ${i * j} \t")
      if (j == i) println()
    }


    //for 循环引入变量
    for (i <- 1 to 10) {
      var j = 10 - i
      println("i= " + i + ", " + "j = " + j)
    }


    println("####################")
    for {
      i <- 1 to 10;
      j = 10 - i
    } {

      println("i= " + i + ", " + "j = " + j)
    }

  }
}
